#ifndef AVCODECSAMPLE_OPENGL_PLUGIN_MANAGER_H
#define AVCODECSAMPLE_OPENGL_PLUGIN_MANAGER_H

#include <ace/xcomponent/native_interface_xcomponent.h>
#include <js_native_api.h>
#include <js_native_api_types.h>
#include <napi/native_api.h>
#include <string>
#include <unordered_map>
#include "native_window/external_window.h"
#include "plugin_render.h"

namespace NativeXcomponentSample {
class PluginManager {
public:
    ~PluginManager();

    static PluginManager *GetInstance() { return &PluginManager::pluginManager_; }

    static napi_value GetContext(napi_env env, napi_callback_info info);

    void SetNativeXComponent(std::string &id, OH_NativeXComponent *nativeXComponent);
    PluginRender *GetRender(std::string &id);
    void Export(napi_env env, napi_value exports);
    OHNativeWindow *pluginWindow_;
    OHNativeWindow *nativeImageWindow_ = nullptr;
private:
    static PluginManager pluginManager_;

    std::unordered_map<std::string, OH_NativeXComponent *> nativeXComponentMap_;
    std::unordered_map<std::string, PluginRender *> pluginRenderMap_;
};
} // namespace NativeXComponentSample

#endif //AVCODECSAMPLE_OPENGL_PLUGIN_MANAGER_H
